package cn.fsd.mapper;

import cn.fsd.domain.Commodity;
import cn.fsd.domain.Storeroom;
import cn.fsd.domain.Storeroom_commodity;
import cn.fsd.query.delivery.StoreroomCommodityQuery;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface Storeroom_commodityMapper {

  int deleteByPrimaryKey(@Param("commodity_id") String commodity_id,
      @Param("storeroom_id") String storeroom_id);

  int insert(Storeroom_commodity record);

  Storeroom_commodity selectByPrimaryKey(@Param("commodity_id") String commodity_id,
      @Param("storeroom_id") String storeroom_id);

  List<Storeroom_commodity> selectAll();

  int updateByPrimaryKey(Storeroom_commodity record);

  /**
   * 分页查询给定仓库内商品 查询条件为库房id
   * @param query 查询条件
   * @return 商品列表
   */
  List<Storeroom_commodity> findCommodityByPage(StoreroomCommodityQuery query);

  /**
   * 更新商品的最高库存量和库存预警值
   * @param storeroomCommodity 库存商品更新后的信息
   */
  void updateMaxLowValues(Storeroom_commodity storeroomCommodity);

  /**
   * 分页获取库房内商品存货数量 查询条件为库房id和商品名字
   *
   * @param query 查询条件
   * @param ids
   * @return 商品列表
   */
  List<Storeroom_commodity> getStoreroomInventoryByPage(StoreroomCommodityQuery query,
      List<String> ids);

  List<Storeroom_commodity> queryOutOfStock(StoreroomCommodityQuery query,List<String> ids);

  void updatePurchase(StoreroomCommodityQuery query);

  /**
   * 根据进货单退货的差额对预计到达的数据进行更新
   */
  void updateReturn(@Param("storeroomId")String storeroomId,@Param("commodityId") String commodityId,@Param("returnNum") Integer returnNum);

  void addCommodityInAllStoreroom(@Param("commodityId")String commodityId,@Param("storerooms") List<Storeroom> storeroomList);

  void addAllCommodityInNewStoreroom(@Param("storeroomId")String storeroomId,@Param("commodities") List<Commodity> commodityList);

  //获取库房的库存量，如果不为0则无法删除
  Storeroom_commodity getStoreValue(String storeroomId);
}